<?php

namespace StudyBuddy;

class SubmittedQuestionWWW extends SubmittedQuestion {

    /**
     * Data submitted via Ask form
     *
     * @var array
     */
    protected $aData;

    public function __construct(Registry $oRegistry, array $aData) {
        $this->oRegistry = $oRegistry;
        $this->aData = $aData;
        d('$this->aData: ' . print_r($this->aData, 1));
        $this->oUser = $oRegistry->Viewer;
    }

    public function getLevel() {
        if (!isset($this->oLevel)) {
            $this->oLevel = $this->aData['level'];
        }

        return $this->oLevel;
    }

    public function getSubject() {
        if (!isset($this->oSubject)) {
            $this->oSubject = $this->aData['subject'];
        }

        return $this->oSubject;
    }

    public function getChapter() {
        if (!isset($this->oChapter)) {
            $this->oChapter = $this->aData['chapter'];
        }

        return $this->oChapter;
    }

    public function getDif() {
        if (!isset($this->oDif)) {
            $this->oDif = $this->aData['dif'];
        }

        return $this->oDif;
    }
    
    public function getUserObject() {
        return $this->oUser;
    }

    public function getIP() {
        return Request::getIP();
    }

    public function getBody() {
        if (!isset($this->oBody)) {
            $this->oBody = Utf8String::factory($this->aData['qbody']);
        }

        return $this->oBody;
    }

    public function getTitle() {
        if (!isset($this->oTitle)) {
            $this->oTitle = Utf8String::factory($this->aData['title']);
        }

        return $this->oTitle;
    }

    /**
     * Returns Tags which is
     * object of type Utf8String
     *
     * (non-PHPdoc)
     * @see StudyBuddy.SubmittedQuestion::getTags()
     */
    public function getUtf8Tags() {
        if (!isset($this->oTags)) {
            $this->oTags = Utf8String::factory($this->aData['tags']);
        }

        return $this->oTags;
    }

    /**
     * (non-PHPdoc)
     * @see StudyBuddy.SubmittedQuestion::getExtraData()
     */
    public function getExtraData() {
        return $this->oRegistry->Geo->Location->data;
    }

    /**
     * Get name of app used for submitting
     * this question
     * @return string
     */
    public function getApp() {
        return 'web';
    }

}
